<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Alpha-欢迎您</title>
    <link rel="shortcut icon" href="../icon/title.ico"/>
    <link rel="stylesheet" href="../css/index.css">
    <link rel="stylesheet" href="../css/bootstrap3.3.7.min.css">

    <script src="../js/jquery-1.10.2.min.js"></script>
    <script src="../js/bootstrap3.3.7.min.js"></script>
    <script src="../js/index.js"></script>
    <style>
        .content{
            width: 80%;margin: auto}
        h3{
            width: 100%;text-align: center;}

    </style>
    <script>

    </script>
</head>
<body>

<div class="warp">
    <div>
        <h1><a href="../index.html">Alpha</a></h1>
    </div>
    <nav class="navbar navbar-default" role="navigation">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse"
                        data-target="#example-navbar-collapse">
                    <span class="sr-only">切换导航</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#"></a>
            </div>
            <div class="collapse navbar-collapse" id="example-navbar-collapse">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="#">javascript</a></li>
                    <li><a href="#">css</a></li>
                    <li><a href="#">jquery</a></li>
                    <li><a href="#">angular</a></li>
                    <li><a href="#">其他</a></li>
                </ul>
            </div>
        </div>
    </nav>
    <div class="img">
        <img src="../images/javaScript.png" style=";height: 300px;background:#ccc;" alt="">
    </div>
    <hr>
    <!--返回顶部箭头-->
    <div id="top" style="width: 50px;height: 50px;background-color: #999;position: fixed;right: 50px;bottom:50px;text-align: center;line-height: 50px;display: none;">
        <b>
            <a style="text-decoration:none;color:#fff;;" href="javascript:;">顶部</a>
        </b>
    </div>

    <div class="content">
        <h3><span>移动端常用语法</span></h3>
        <p>添加下面标签页使面自由缩放：</p>
        <pre>< meta name="viewport" content="width=device-width, initial-scale=1"></pre>
        <p>用JS使页面font-size：按比例显示：</p>
        <pre>
            (function(win,doc){
                //  resize就是onresize事件;  当页面窗口没改变时触发该事件
                win.addEventListener('resize',change,false);
                function change(){
                    //以320屏幕为基础  也就是屏幕的宽度乘以20  是html的初始字体大小
                    doc.documentElement.style.fontSize=doc.documentElement.(clientWidth/320)*20+'px';
                    //**假如说屏幕宽度刚好是320px，该方法的font-size刚好是20px;如果说窗口大小不是320,
                    上面有个meta标签它的作用是等比例缩放,刚好达到自适应效果,何乐而不为呢;
             }
                change();
            })(window,document)

            *****使用rem的时候移动要除以20  因为默认字体是20px;
        </pre>
        <p>
            什么是rem：
            <p>W3C官网描述是“font size of the root element”，即rem是相对于根元素,
        我们只需要在根元素确定一个参考值，在根元素中设置多大的字体，这完全可以根据您自己的需.
            </p>
        </p>
    </div>
    <hr>
    <div class="footer">
        <div>
            <img src="" alt="">
            <img src="" alt="">
            <img src="" alt="">
            <img src="" alt="">
            <img src="" alt="">
            <img src="" alt="">
        </div>
        <div class="footer-bottom">
            <p>这是一段内容</p>

        </div>
    </div>
</div>

</body>
</html>
<script>
    window.addEventListener('scroll', function () {
        var oTop=document.getElementById('top');
        var oH=document.documentElement.clientHeight;
        var oS=document.body.scrollTop;
        if(oH+oS>oH){
            oTop.style.display="block";

        }else {
            oTop.style.display="none";
        }
        oTop.onclick= function () {
            var timer=null;
            clearInterval(timer);
            timer=setInterval(function () {
                console.log(oS)
                document.body.scrollTop=(oS*=0.8);
                if (oS<=1){
                    oS=0;
                    clearInterval(timer);
                    oTop.style.display="none";
                    //alert(oS)
                }
                console.log(oS)
            },30)
        }
    },false);
</script>